home *** CD-ROM | disk | FTP | other *** search
- /*XOCMD.C Command parsing/execution module for XOBBS. Jim Durham, W2XO 04-16-89*/
- /*Version 1.4 */
- /*Code released to the amateur radio community*/
-
- #include "xobbs.h"
-
- parse()
- {
- int i,j;
- char *cp;
-
- for(i=0;i<10;i++)
- command.fld[i][0] = '\0'; /*blank the command structure*/
-
- command.opt=' ';
-
- command.func=inline[0]; /*first letter is command*/
-
- if(inline[0]=='['){
- revfwd=true;
- return(0);
- }
-
- switch(inline[1])
- {
- case ' ': i=1; /*point to the blank 2nd char*/
- break;
- case '\0': return 1; /* done, go back*/
- break;
-
- default: command.opt=inline[1]; /*assign option*/
- i=2;
- break;
- }
-
- j=1;
- while(j < 10 )
- {
- while(inline[i]==' ') i++; /*ratchet past any blanks*/
- if(inline[i]=='\0') return 1; /*ok if just blanks ends the line*/
- cp=command.fld[j]; /*point to the first field*/
- while(inline[i] != ' ' && inline[i]) /*while not EOL or blank*/
- *cp++ =inline[i++]; /*copy chars to field*/
- *cp='\0';
- j++;
- }
- return 1;
- }
-
- docmd()
- {
- char cmdstr[40];
- if(!fwding){
- switch(command.func)
- {
- case '[': revfwd=true;
- break;
- case 'U':
- case 'u': sprintf(cmdstr,"%s%s",filedir,command.fld[1]);
- upload(cmdstr);
- break;
- case 'D':
- case 'd': sprintf(cmdstr,"%s%s",filedir,command.fld[1]);
- download(cmdstr);
- break;
- case 'K':
- case 'k': switch(command.opt){
- case 'M':
- case 'm': killmine();
- break;
- default: killmsg();
- break;
- }
- break;
- case 'S':
- case 's': sendmsg(0);
- if(dpid != 0) kill(dpid,16); /*tell the maildaemon to do its thing*/
- break;
- case 'R':
- case 'r': readmail();
- break;
- case 'W':
- case 'w': sprintf(cmdstr,"%s%s",filedir,command.fld[1]);
- if(command.fld[1][0] == '\0')
- dodir(cmdstr,0);
- else
- dodir(cmdstr,1);
- break;
- case 'L':
- case 'l': lsthdrs();
- break;
- case 'F':
- case 'f': if(command.opt == '>')
- dofwd();
- else
- makefil();
- break;
- case 'B':
- case 'b':
- case 'Q':
- case 'q':
- sndupkil();
- break;
-
- case 'I':
- case 'i': sprintf(cmdstr,"%sinfo.xo",homedir);
- download(cmdstr);
- break;
- case 'M':
- case 'm': sendmsg(1);
- if(dpid != 0) kill(dpid,16); /*tell the maildaemon to do its thing*/
- break;
- case 'N':
- case 'n': doname(command.fld[1]);
- break;
- case 'E':
- case 'e': if((command.opt=='U') || (command.opt=='u'))
- edituser(command.fld[1]);
- break;
- case 'H':
- case 'h': sprintf(prinbuf,"Select the Type of Help\n\n");
- prinout(NOFLUSH);
- sprintf(prinbuf,"D. Help with Downloading Files\n");
- prinout(NOFLUSH);
- sprintf(prinbuf,"K. Help with Killing Messages\n");
- prinout(NOFLUSH);
- sprintf(prinbuf,"L. Help with Listing Messages\n");
- prinout(NOFLUSH);
- sprintf(prinbuf,"R. Help with Reading Messages\n");
- prinout(NOFLUSH);
- sprintf(prinbuf,"S. Help with Sending Messages\n");
- prinout(NOFLUSH);
- sprintf(prinbuf,"U. Help with Uploading Files\n");
- prinout(NOFLUSH);
- sprintf(prinbuf,"W. Help with File Directories\n\n");
- prinout(NOFLUSH);
- sprintf(prinbuf,"**Type Letter of Function Selected**\n");
- prinout(FLUSH);
- getline();
- strcpy(cmdstr,homedir);
- switch(inline[0]){
- case 'D': strcat(cmdstr,"download.hlp");
- break;
- case 'K': strcat(cmdstr,"killmesg.hlp");
- break;
- case 'L': strcat(cmdstr,"listmesg.hlp");
- break;
- case 'R': strcat(cmdstr,"readmesg.hlp");
- break;
- case 'S': strcat(cmdstr,"sendmesg.hlp");
- break;
- case 'U': strcat(cmdstr,"upload.hlp");
- break;
- case 'W': strcat(cmdstr,"filedir.hlp");
- break;
- }
- download(cmdstr);
- break;
-
- default: printerr();
- break;
- }
- }
- else
- confwd(); /*this is a forwarding session, so do it! */
- }
-
-